﻿using System.Windows.Forms;
using Components;
using UI.Lib;

namespace UI.Invoice
{
    public partial class FrmTic1a10Edit : UI.ParentForm.BaseEdit
    {
        public FrmTic1a10Edit(string action, string text, string key)
            : base(action)
        {
            InitializeComponent();

            this.Text = text;
            this.key = key;
            //回写的方法
            this.SaveCallFuntion = "Tic1a10Manager$SaveEditData"; //保存的方法

            {
                LoadData();
            }

            this.Size = base.LargeWindow;
        }

        public override bool BeforePopWin(string name, ref string where, ref string[] others)
        {
            if ("sellercode" == name)
            {
                where = string.Format(" status ='1' {0} ", Context.GetAppKeyWhere("usercode", true));
            }
            else if ("shopcode" == name)
            {
                var sellerid = Validation.ToString(this.tbSummary.GetValue("cesellerid"));
                if (string.IsNullOrEmpty(sellerid))
                {
                    MessageBox.Show("请先选择销售商！", "提示");
                    this.tbSummary.Focus("sellercode");
                    return false;
                }

                where = string.Format("slistid = '{0}' {1} ", sellerid, Context.GetAppKeyWhere("muser", true));
            }
            else if ("subcode" == name)
            {
                where = string.Format("substatue = '1' {0} ", Context.GetAppKeyWhere("usercode", true));
            }

            return true;
        }

        //加载修改数据
        private void LoadData()
        {
            base.LoadEditData(null, string.Format(" ceid ='{0}' ", this.key));
        }
    }
}